<!-- 安排考试  选择试卷 -->
<template>
    <div>
        <el-skeleton :rows="8" :loading="loading" animated>
            <el-table :data="tableData" row-key="id" border height="50vh" ref="myTable" style="width: 100%;">
                <el-table-column prop="id" v-if="false" label="编号" align="center" />
                <el-table-column type="index" label="序号" align="center" width="80" />
                <el-table-column prop="name" label="职务/岗位" align="center" width="180" />
                <el-table-column label="职务/岗位" align="center">
                    <template #default="scope">
                        <el-popconfirm confirm-button-text="确认" cancel-button-text="取消" icon="InfoFilled" width="200px"
                            icon-color="#626AEF" title="确认选择该职务吗？" @confirm="select(scope.row)">
                            <template #reference>
                                <el-button slot="reference" size="small" type="primary">
                                    请选择</el-button>
                            </template>
                        </el-popconfirm>
                    </template>
                </el-table-column>
            </el-table>
        </el-skeleton>
    </div>
</template>

<script lang="ts">
import { defineComponent, getCurrentInstance, onMounted, reactive, toRefs } from 'vue'
import { GetZhiwuList } from '../../../api/user/user'
import { useRoute } from 'vue-router';
export default defineComponent({
    props: ["lv", "ids", "names"],
    setup(props, context) {
        const route = useRoute();
        const { ctx } = getCurrentInstance() as any;
        //界面加载时发生
        onMounted(() => {
            event.datas();
        })
        const shujudata = reactive({
            loading: true,
            page: 1,
            limit: 999,
            tableData: [],
            lv: '',
            ids: '',
            names: '',
        })
        const event = {
            select(item: any) {
                var obj = {
                    oid: props.ids,
                    zid: item.id,
                    zname: item.name,
                    oname: props.names,
                }
                context.emit("zhiwu", obj)
                console.log("请选择----------", obj)
            },
            datas: function () {
                var obj = { page: shujudata.page, limit: shujudata.limit };
                GetZhiwuList(obj).then((res: any) => {
                    if (res.result == 0) {
                        res.data.data.forEach((item: any) => {
                            if (item.lv >= shujudata.lv) {
                                shujudata.tableData.push(item)
                            }
                        })
                    }
                    shujudata.loading = false;
                });
            }
        }
        return {
            ...toRefs(shujudata),
            ...event,
        }
    },
})
</script>
  
<style scoped>
.btns {
    padding-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>















